{% extends 'base.html' %}
{% from 'macros.html' import render_nav_item %}

{% block title %}Dashboard{% endblock %}

{% block navbar %}
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('front.index') }}">
                <img src="{{ url_for('static', filename='navbar-brand.ico') }}" alt="MMCs" width="80">
            </a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
                    aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>

            <div class="collapse navbar-collapse" id="navbarSupportedContent">
                <div class="navbar-nav ml-auto">
                    {{ render_nav_item('front.index', _('Dashboard'), "oi oi-dashboard") }}
                    <a class="nav-item nav-link" data-toggle="modal" data-target="#aboutModal">
                        <span class="oi oi-info"></span> {{ _('Notice') }}</a>
                    <div class="dropdown nav-item">
                        <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">
                            <span class="oi oi-wrench"></span> {{ _('Manage') }}
                        </a>
                        <div class="dropdown-menu" role="menu">
                            {% if current_user.is_root %}
                                <a class="dropdown-item"
                                   href="{{ url_for('root.index') }}">{{ _('Overview') }}</a>
                                <a class="dropdown-item"
                                   href="{{ url_for('root.manage_competition') }}">{{ _('Competition Management') }}</a>
                                <a class="dropdown-item"
                                   href="{{ url_for('root.manage_personnel') }}">{{ _('Personnel Management') }}</a>
                            {% elif current_user.is_admin %}
                                <a class="dropdown-item"
                                   href="{{ url_for('admin.index') }}">{{ _('Overview') }}</a>
                                <a class="dropdown-item"
                                   href="{{ url_for('admin.manage_solution') }}">{{ _('Solution Management') }}</a>
                                <a class="dropdown-item"
                                   href="{{ url_for('admin.manage_task') }}">{{ _('Task Management') }}</a>
                                <a class="dropdown-item"
                                   href="{{ url_for('admin.manage_score') }}">{{ _('Score Management') }}</a>
                            {% elif current_user.is_teacher %}
                                <a class="dropdown-item"
                                   href="{{ url_for('teacher.index') }}">{{ _('Overview') }}</a>
                                <a class="dropdown-item"
                                   href="{{ url_for('teacher.manage_task') }}">{{ _('Task Management') }}</a>
                            {% endif %}
                        </div>
                    </div>
                    <div class="dropdown nav-item">
                        <a class="nav-link dropdown-toggle" data-toggle="dropdown">
                            <span class="oi oi-globe"></span> {{ _('Language') }}
                        </a>
                        <div class="dropdown-menu" role="menu">
                            <a class="dropdown-item"
                               href="{{ url_for('front.set_locale', locale='zh_Hans_CN') }}">简体中文</a>
                            <a class="dropdown-item"
                               href="{{ url_for('front.set_locale', locale='en_US') }}">English</a>
                        </div>
                    </div>
                    <div class="dropdown nav-item">
                        <a class="nav-link dropdown-toggle" data-toggle="dropdown">
                            <span class="oi oi-person"></span>
                        </a>
                        <div class="dropdown-menu" role="menu">
                            <h6 class="dropdown-header">{{ _('Logged in as') }} {{ current_user.realname }}</h6>
                            <a class="dropdown-item" href="{{ url_for('backstage.edit_profile') }}">
                                <span class="oi oi-cog"></span> {{ _('Settings') }}</a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item"
                               href="{{ url_for('auth.logout', next=request.full_path) }}">
                                <span class="oi oi-account-logout"></span> {{ _('Logout') }}</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </nav>

    <!-- notice modal -->
    <div class="modal fade" id="aboutModal" tabindex="-1" role="dialog" aria-labelledby="aboutModalTitle"
         aria-hidden="true">
        <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="aboutModalTitle">{{ _('Notice') }}</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        <span class="oi oi-delete"></span>
                    </button>
                </div>
                <div class="modal-body">
                    {{ render_text("showing/notice.html")|safe }}
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        {{ _('Close') }}
                    </button>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
